package com.atguigu.gmall.pms.vo;

import com.atguigu.gmall.pms.entity.SpuAttrValueEntity;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * baseAttrs 下还有一个属性 valueSelected  是集合,在定义一个Vo接收数据
 */
@Data
public class SpuAttrValueVo extends SpuAttrValueEntity {

    public void setValueSelected(List<String> valueSelected) {
        if (CollectionUtils.isEmpty(valueSelected)){
            return;
        }

        //StringUtils.join 将 valueSelected 用 ,   拼接 成字符串
        this.setAttrValue(StringUtils.join(valueSelected,","));
    }
}
